﻿using System;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SwinGame;

namespace SimpleSurvival.src
{
    //-----------------------------------------------//
    //INTERFACE - ICamera.cs
    //-----------------------------------------------//
    //Most likely overkill
    public interface ICamera
    {
        void ResetCameraPos();
        void MoveCamera(double dx, double dy, double dt);
        Vector GetRelativePosition(Vector v);
        int getLeftBounds();
        int getRightBounds();
        int getTopBounds();
        int getBottomBounds();
    }

    //-----------------------------------------------//
    //CLASS - Camera.cs
    //-----------------------------------------------//
    public class Camera : ICamera
    {
        //Difference in position to Game Co-Ords
        Vector _offset = new Vector();

        //Speed at which camera moves
        double _speed = 400;

        //Resets the CameraPos to (0,0)
        public void ResetCameraPos()
        {
            _offset.X = 0;
            _offset.Y = 0;
        }

        //Moves the camera in a desired direction
        public void MoveCamera(double dx, double dy, double dt)
        {
            _offset.X += (float)(dx * dt * _speed);//fix
            _offset.Y += (float)(dy * dt * _speed);//fix
        }

        //Converts game co-ords to screen co-ords
        public Vector GetRelativePosition(Vector v)
        {
            return new Vector { X = v.X - _offset.X, Y = v.Y - _offset.Y };
        }

        //returns the boundaries of the camera
        public int getLeftBounds() { return (int)_offset.X; }
        public int getRightBounds() { return (int)_offset.X + GameMain.SCREEN_WIDTH; }
        public int getTopBounds() { return (int)_offset.Y; }
        public int getBottomBounds() { return (int)_offset.Y + GameMain.SCREEN_HEIGHT; }
    }
}
